import previewImage from "@/components/preview/previewImage"
import { render } from "vue"

const useImagePreview = (options) => {
    const mountNode = document.createElement("div")

    if (!options) return
    mountNode.id = "previewImage"
    document.body.appendChild(mountNode)
    const vNode = h(previewImage, {
        ...options, onClose: () => {
            setTimeout(() => {
                document.body.removeChild(mountNode)
            }, 200);
        }
    })
    render(vNode, mountNode)
}

export default useImagePreview